<template>
	<view>
		<tab-title :tabTitle='title'></tab-title>
		<view class="top">
			<view class="container">
				<view class="container-text">
					<text>验证码类型</text>
					<text>核销码</text>
				</view>
				<view class="cu-form-group">
					<input placeholder="请输入核销码" name="input" v-model="offCode"></input>
				</view>
			</view>
		</view>
		<view class="center" v-if="isShow">
			<view class="container">
				<view class="center-title">
					订单明细
				</view>
				<view>
					<text class="center-right">订单号</text>
					<text style="margin-left: 25upx;">20190410324135431</text>
				</view>
				<view>
					<text class="center-right">商品名称</text>
					<text>香辣虾</text>
				</view>
				<view>
					<text class="center-right">订单日期</text>
					<text>2019-04-10</text>
				</view>
				<view>
					<text class="center-right">实付价格</text>
					<text>¥ 251</text>
				</view>
			</view>
		</view>
		<view class="bottom-btn">
			<view class="flex flex justify-between" v-if="!isShow">
				<button class="cu-btn line-blue block margin-tb-sm lg" @click="scanOffcode">扫码核销</button>
				<button class="cu-btn line-blue block margin-tb-sm lg" @click="getoffOrder">输入核销</button>
			</view>
			<view class="flex justify-center" v-else>
				<button class="cu-btn line-blue block margin-tb-sm lg" @click="offOrder">核销</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isShow:false,
				offCode:'',
				detail:{},
				title:'输入核销码'
			};
		},
		methods:{
			// 输入核销
			getoffOrder(){
				// if(!this.offCode){
				// 	uni.showToast({
				// 		title:'核销码不能为空',
				// 		duration:1500,
				// 		icon:'none'
				// 	})
				// } else {
				// 	let userInfo = uni.getStorageSync('userInfo')	
				// 	this.$http.post('assemble/businessOrdr/getOffOrder',{
				// 		storeId:userInfo.storeId,
				// 		offCode:this.offCode
				// 	}).then((res) => {
				// 		if(res.data.flag){
				// 			this.detail = res.data.data;
				// 			this.isShow = true;
				// 			console.log(this.detail)
				// 		}else{
				// 			uni.showToast({
				// 				title:res.data.message,
				// 				icon:'none'
				// 			})
				// 		}
				// 	}).catch((err)=>{
				// 	uni.showToast({
				// 		title:'网路错误,请稍后重试',
				// 		icon:'none'
				// 	})
				// })
				// }
				this.isShow = true;
				console.log(1)
			},
			//扫描核销
			scanOffcode(){
				uni.scanCode({
					success:(res)=>{
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
							this.offCode = res.result;
							console.log(this.offCode)
							this.getoffOrder()
					}	
				})
			},
			// 确认核销
			offOrder(){
				uni.redirectTo({
					url:'/pages/hexiaoSuccess/hexiaoSuccess'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		overflow: hidden;
		
	}

	.top {
		width: 100%;
		border-bottom: 15upx solid #EEEEEE;
		.container {
			width: 718upx;
			margin: 0 auto;
			.container-text {
				height: 108upx;
				font-size: $font30;
				line-height: 108upx;
				border-bottom: 1upx solid #eeeeee;
				text:nth-child(1) {
					margin-right: 111upx;
					color: #999999;
				}
			}

			.cu-form-group {
				padding: 0;
			}
		}
	}

	.center {
		width: 718upx;
		height: 472upx;
		margin: 0 auto;
		view {
			height: 95upx;
			line-height: 95upx;
			border-bottom: 1upx solid #eeeeee;
			letter-spacing: 2upx;
		}

		.center-title {
			font-size: $font30;
		}
		.center-right {
			display: inline-block;
			font-size: $font28;
			color: #999999;
			margin-right: 179upx;
		}
	}
	
	.bottom-btn{
		width: 718upx;
		position: absolute;
		left: 15upx;
		bottom: 25upx;
		button{
			width: 329rpx;
			height: 80rpx;
			color: #ffffff;
		}
		button:nth-child(2){
			margin-left: 32upx;
		}
		.cu-btn[class*="line"] {
			background-color: $global-bgc;
			color: #FFFFFF;
			letter-spacing: 5upx;
		}
	}
</style>
